Subject: MidStr
From: "Barry D. Wills" <[email-masked]>
To: "amigae" <[email-masked]>
Date: 29 Jul 93 09:21:00 CST

Hi, Jeffrey.  In response to your message:

>    I can't get MidStr() to work right.  It is reading it from the starting
>point right, but I can't get it to stop! I am trying to get a version string
>pulled out of a buffer I am getting from Read(). Before vtst was defined as a
>string, it was working somewhat well (I was getting what I wanted), but I am
>not sure whether it was stoping where I wanted. What I need is the original
>version string, with the revision number bumped up by one.

=======================================================================

PROC findver(pos) /* pos is found in the prior proc */
  DEF endpos,
      vers,
      per,
      vn,
      vp,
      vns,
      nvers,
      rvers,
      vtst[80]:STRING

  endpos:=InStr(filbuf,'\n',pos) /* finding then end of the line */
*******************************************************************************
*** Your problem starts here.  vers is uninitialized, so it contains a value
*** that looks like an address.  MidStr() copies characters to the nonexistent
*** string at "address" vers.  You need to declare these as STRING or allocate
*** the using String().   Basically, this is copying characters into random 
*** memory locations, a very effective way to corrupt your memory :(  I noticed
*** this happening in several places in the code that follows this statement. 
***
  MidStr(vers,filbuf,pos,endpos-pos)

[statements removed]

*** StringF() still might work under lucky circumstances.
  StringF(vtst,'\s \d.\d',nvers,vp,rvers)

*** As for your run-on problem, it may be a symptom of this.  If it persists
*** then post, post again!  :-)

Later.
-- Barry